//
//  OneViewController.m
//  5-31学习
//
//  Created by 钟纪旺 on 16/5/31.
//  Copyright © 2016年 zjw. All rights reserved.
//

#import "OneViewController.h"

@interface OneViewController ()
@end

@implementation OneViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationController.title = @"too";
    self.view.backgroundColor = [UIColor whiteColor];
    // Uncomment the following line to preserve selection between presentations.
    // self.clearsSelectionOnViewWillAppear = NO;
    
    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
    //设置按钮
    UIButton *btn =[UIButton buttonWithType:UIButtonTypeSystem];
    //使用文字设置
    [btn setTitle:@"按钮" forState:UIControlStateNormal];
    [btn setTitle:@"按下去了" forState:UIControlStateHighlighted];
    [btn setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    //用本地图片设置按钮
//   [btn setImage:[UIImage imageNamed:@"2"] forState:UIControlStateNormal];
    //设置宽度
    btn.layer.borderWidth = 1;
    //边框设置为圆角
    btn.layer.cornerRadius = 6;
    //设置宽与高
    btn.frame = CGRectMake(0, 0, 144, 44);
    btn.center = CGPointMake(self.view.frame.size.width/2, 100);
    [btn addTarget:self action:@selector(omg:) forControlEvents:UIControlEventTouchUpInside];
    [btn addTarget:self action:@selector(omg2:) forControlEvents:UIControlEventTouchDown];
    [self.view addSubview:btn];
    UILabel *l =[[UILabel alloc] initWithFrame:CGRectMake(200, 150, 100, 44)];
    l.text = @"苹果1512";
    l.tag =100;
    l.shadowColor =[UIColor yellowColor];
    
    [self.view addSubview:l];
    //UISwith 类似于开关样式
    UISwitch *d =[[UISwitch alloc] initWithFrame:CGRectMake(10, 100, 100, 44)];
    d.onTintColor =[UIColor redColor];
    d.on = YES;
    [d addTarget:self action:@selector(omg4:) forControlEvents:UIControlEventValueChanged];
    [self.view addSubview:d];
    
    //UISlider 类似可拉动的
    UISlider *a =[[UISlider alloc] initWithFrame:CGRectMake(16, 200, 100, 44)];
    [self.view addSubview:a];
    //UIProgressView 进度条
    UIProgressView *b =[[UIProgressView alloc] initWithFrame:CGRectMake(16, 300, 100,44)];
    [self.view addSubview:b];
    //UIActivityIndicatorView 提供轻型视图，会显示一个标准的旋转进度轮
//    UIActivityIndicatorView *c =[[UIActivityIndicatorView alloc]initWithFrame:CGRectMake(16, 400, 100, 44)];
//    [self.view addSubview:c];
    //UISegmentedControl类似于UIButton,它可以提供多个选择操作,响应事件,但具有很大的局限性,我们更多的是使用自定义
//    UISegmentedControl *seg =[UISegmentedControl alloc] initWithItems:@[@"向左",@"居中",@"向右"]
//    
    
}
//- (void)onSeg:(UISegmentedControl *)seg{
//
//    UILabel *l =(UILabel *)[self.view viewWithTag:100];
//    if (seg.selectedSegmentIndex == 0) {
//        l.center =CG
//    }
//
//
//
//
//
//}
- (void)omg:(UIButton *)sender{
    sender.backgroundColor =[UIColor greenColor];




}
- (void)omg2:(UIButton *)sender{
    sender.backgroundColor =[UIColor blueColor];
    
    
    
    
}
- (void)omg3:(UISwitch *)swi {
    UILabel *l =(UILabel *)[self.view viewWithTag:100];
    
    if (swi.isOn) {
        l.layer.borderWidth = 1;
        l.textColor =[UIColor blueColor];
    }else {
        l.layer.borderWidth = 0;
    l.textColor =[UIColor yellowColor];
    }

}
// 控制开关修改背景颜色
- (void)omg4:(UISwitch *)swi2 {
    if (swi2.isOn) {
        self.view.backgroundColor =[UIColor blackColor];
    }else{
    
        self.view.backgroundColor =[UIColor whiteColor];
    
    }




}
//- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
//
//
//    return 1;
//
//}
//-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
//    UITableViewCell *cell =[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
////    if (!tf) {
////        tf = [UITextField alloc] initWithFrame:CGRectMake(0, 0, self.view.frame, 44);
////    }
////
//
//
////}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
